﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Web7.Ioc;

namespace Web7.Domain
{
    public interface IRepository<T, TId> : IDependency where T : Entity<TId>
    {
        void Create(T entity);
        void Update(T entity);
        void Delete(T entity);
        void Delete(IEnumerable<T> entity);
        void Delete(params TId[] ids);
        void Delete(Expression<Func<T, bool>> predicate);
        void Copy(T source, T target);
        void Flush();

        T Get(TId id);
        T Get(Expression<Func<T, bool>> predicate);

        IQueryable<T> Table { get; }

        int Count(Expression<Func<T, bool>> predicate);
        IEnumerable<T> Fetch(Expression<Func<T, bool>> predicate);
        IEnumerable<T> Fetch(Expression<Func<T, bool>> predicate, Action<Orderable<T>> order);
        IEnumerable<T> Fetch(Expression<Func<T, bool>> predicate, Action<Orderable<T>> order, int skip, int count);
    }

    public interface IRepository<T> : IRepository<T, Guid> where T : Entity
    {

    }
}
